
$(function() {
 
    $('#defaultReal').realperson();
    var icons = {
        header: "ui-icon-circle-arrow-e",
        activeHeader: "ui-icon-circle-arrow-s"
    };
    // Make accordion feature of jQuery-UI
    $("#accordion").accordion({icons: icons, heightStyle: "content"});
    // Load example of form validation
    var formulario = '';
    
    
    
    $('form').submit(function(e) {
       
       
        var $form = $(this);
        //var $target = $('#respuesta');

        $.ajax({
            type: $form.attr('method'),
            dataType: "json",
            url: $form.attr('data-target'),
            cache: false,
            data: $form.serialize(),
            success: function(data) {
                console.debug(data);
               
                    if (data.res) {
                        location = 'feria/index';
                    } else {
                        $('#myModel .modal-body').html('<div class="alert alert-danger"><i class="fa fa-exclamation-triangle"></i><strong>¡Error!</strong> ' + data.mensaje + '<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button></div>');
                        $('#myModel').modal('show');
                    }
                
               
            }
        });
        e.preventDefault();
    });
    
  
    // estilo del comentario del campo
    $('.form-control').tooltip();
  

});


    
